<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="utf-8" lang="utf-8">
	<head>
		<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
		<meta name="ROBOTS" content="all" />
		<title><?php echo $_title?></title>
		<meta name="description" content="" />
		<meta name="keyword" content="" />
		<link rel="stylesheet" type="text/css" href="/theme/<?=$_theme?>/common/css/admin.css" id="stylesheet" />
		<style type="text/css">
			td.content{min-height:500px;vertical-align:top}
		</style>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/jquery-latest.js"></script>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/gnb.js"></script>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/v_navi.js"></script>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/tree.js"></script>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/jquery.cookie.js"></script>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/jquery.hotkeys.js"></script>
		<script type="text/javascript" src="/theme/<?=$_theme?>/common/js/jquery.jstree.js"></script>

		<script type="text/javascript">
			//<![CDATA[

			//]]>
		</script>
	</head>

	<body id="layout">
		<table width="100%" border="1" cellpadding="0" cellspacing="0">
		<tr>
			<td colspan="2" height="100">
			
			<?php
			
//			$filename = './theme/'.$_theme.'/admin.xml';
//            $xmlfile= $filename;
//            $xmlRaw = file_get_contents($xmlfile);
//			$xmlData = $this->simplexml->xml_parse($xmlRaw);
//			
//			echo "<ul class=\"topMenu\">\n";
//			foreach($xmlData['top'] as $row){
//				echo "<li>".$row['left']."</li>\n";					
//				//echo "<li><a href=\"/chmanager".$row['@attributes']['link']."\">".$row['@attributes']['title']."</a></li>\n";					
//			}
//			echo "</ul>\n";
			
			//Get the XML document loaded into a variable
			$xml = file_get_contents('./theme/'.$_theme.'/admin.xml');
			//Set up the parser object
			$parser = new XMLParser($xml);

			//Work the magic...
			$parser->Parse();
			echo "<ul class=\"topMenu\">\n";
			$_topIndex = 0;
			$_leftIndex =0; 	
			foreach($parser->document->menu as $menu){
				echo "<li><a href=\"/chmanager".$menu->hyperlink[0]->tagData."\">".$menu->menuname[0]->tagData."</a></li>\n";
				
				//$values = array_keys($parser->document->menu);
				//echo print_r($values); 
				
				foreach($parser->document->menu[$_topIndex]->menuitem as $left) {
					//echo $_content;
					//echo $_topIndex.'=>'.$_content.'========================='.$left->hyperlink[0]->tagData.'<p>';
					//$_leftLink = explode('/',$left->hyperlink[0]->tagData);
					//echo '<p>'.uri_string().' : '.$left->hyperlink[0]->tagData.' : '.strpos(uri_string(),$left->hyperlink[0]->tagData).'</p>';	
					if(strpos(uri_string(),$left->hyperlink[0]->tagData) > 0 ){
						$_leftIndex = $_topIndex;
					break;	
					}
					//echo "<li>".$left->menuitemname[0]->tagData."</li>\n";
				}
				$_topIndex++;	
				//echo "<li>".$menu->menuitemname[0]->tagData."</li>\n";
				//foreach($menu->menuitem as $item){
					//echo "<li><a href=\"/chmanager".$menu->hyperlink[0]->tagData."\">".$menu->menuname[0]->tagData."</a></li>\n";
				//}
				//echo '<p>'.print_r($menu).'</p>';

//				//If the rating is in stars...
//				if($rating->tagAttrs['type'] == 'stars')
//					echo $rating->tagData.' stars';
//
//				//If the rating is in thumbs...
//				if($rating->tagAttrs['type'] == 'thumbs')
//					echo $rating->tagData.' thumbs up';
				
			}
			echo "</ul>\n";
			?>
			</td>
		</tr>
		<tr>
			<td width="15%" style="vertical-align:top">
			<?php
			echo "<ul class=\"leftMenu\">\n";
			foreach($parser->document->menu[$_leftIndex]->menuitem as $menu){
				
					echo "<li><a href=\"/chmanager".$menu->hyperlink[0]->tagData."\">".$menu->menuitemname[0]->tagData."</a></li>\n";		   				
			}
			echo "</ul>\n";
			

//				//print_r($xmlData);
//				//echo is_array($xmlData,'contents');	
//				$_left = explode('/',uri_string());
//				
//				echo "<ul class=\"leftMenu\">\n";
//				foreach($xmlData['top'] as $row){
//					//print_r($row['left']).'<p />';
//					//echo is_array('contents',$row['left']);
//					/*if(strpos($row['@attributes']['link'],$_left[1]) == 1 ){	
//						foreach($row['left'] as $cols){
//							echo "<li><a href=\"/chmanager".$cols['@attributes']['link']."\">".$cols['@attributes']['title']."</a></li>\n";
//						}
//					}*/
//				}
//				echo "</ul>\n";
			?>
			</td>
			<td class="content">
			<?php 
				$this->load->view($_content);
			?>
			</td>	
		</tr>
		<tr>
			<td colspan="2" height="100">Bottom</td>
		</tr>
		</table>
	</body>
</html>